﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtWidgets/QMainWindow>
#include "ui_mainwindow.h"
#include "../include/view.h"
#include "include/global.h"
class QHBoxLayout;
class QDockWidget;
class TreeWidget;
class QTreeWidgetItem;
class TableWidget;
class DataWidget;
class HLed;
class HLeds;
class QextSerialPort;
class QLabel;
class SQLThread;
class QTcpSocket;
class QTreeWidgetItem;
class DataFactory;
class MainWindow : public QMainWindow
{
	Q_OBJECT

public:
	MainWindow(QWidget *parent = 0);
	~MainWindow();
    HLed* led[N_LEDS]; //status leds
    HLeds* leds;  //stream Leds
    QLabel *dateLabel;//date label

private:
	Ui::MainWindowClass ui;
    QWidget* mainWidget;
	//QDockWidget *mainDock;
	TreeWidget *mainTreeWidget;
	QTableWidget *mainTableWidget;
	DataWidget *dataWidget;
    DataFactory *dataFactory; // very important
	int stationLeafNums;
	QTreeWidgetItem *itemCollectionStation;
	int stationsNums;
	int currentStation;
	int currentRow;

private:
    void initObject();
	void initTreeWidget();
	void initTableWidget();
	void initTableWidgetData();
    void buildWithFactoryRelations();
	void initTreeWidgetData();

private Q_SLOTS:
    void acceptFromTreeWidget(QTreeWidgetItem * item, int column); //
	void addNewTableItem();
	void updateTableItem(int);
     void socketConnected();
     void socketDisconnected();
     void haveError();
     void updateDataWidgetWaveUI(int stationNo, int sensorType, int sensorNo, float data);
     void checkSomethingsAndUpdateUI(long t);
public Q_SLOTS:
     void uartStatesUpdate(bool flag = false);
     void sqlStatesUpdate(const QString& txt);
	 void sqlUpdateLed(bool flag);
	 void sqlLedOpen(){
		 sqlUpdateLed(true);
	 }
	 void tableLineSelected();
	 void getItem(int row, int column);

};

#endif // MAINWINDOW_H
